Skip to content

fix handling of null groupConfiguration#1130

Merged
jlizen merged 4 commits intoaws:mainfrom
jct-tympanon:main
Mar 19, 2026
Merged

fix handling of null groupConfiguration#1130
jlizen merged 4 commits intoaws:mainfrom
jct-tympanon:main

Conversation

@jct-tympanon
Copy link
Contributor

Fixes #1129 .

📬 Issue #, if available: 1129

✍️ Description of changes: I added the "nullish" serde function and test emulating similar treatment for nullish boolean and map fields. this addresses the problem with the groupConfiguration field discussed in the issue report.

i think the new deserialize_nullish function could supersede deserialize_nullish_boolean, deserialize_lambda_map, and possibly deserialize_lambda_dynamodb_item. but i left that out for a potential follow-up PR, to keep the blast radius small.

🔏 By submitting this pull request

  • I confirm that I've ran cargo +nightly fmt.
  • I confirm that I've ran cargo clippy --fix.
  • I confirm that I've made a best effort attempt to update all relevant documentation.
  • I confirm that my contribution is made under the terms of the Apache 2.0 license.

Fixes aws#1129 .

I added the "nullish" serde function and test emulating similar treatment for nullish boolean and map fields. i think the new deserialize_nullish function could supersede deserialize_nullish_boolean, deserialize_lambda_map, and possibly deserialize_lambda_dynamodb_item. but i left that out for a potential follow-up PR, to keep the blast radius small.
Copy link
Collaborator

@jlizen jlizen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable, just some small doc tweaks

#[serde(deserialize_with = "deserialize_lambda_map")]
#[serde(default)]
pub user_attributes: HashMap<String, String>,
#[serde(default, deserialize_with = "deserialize_nullish")]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we give this field a doc comment mentioning the "null-ish as default" semantics?

#[serde(deserialize_with = "deserialize_lambda_map")]
#[serde(default)]
pub user_attributes: HashMap<String, String>,
#[serde(default, deserialize_with = "deserialize_nullish")]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we give this field a doc comment mentioning the "null-ish as default" semantics?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do (and the other occurrence)

addressed review feedback for aws#1129 .

all of the implementations for the removed functions were identical, so they are exactly
equivalent to the generic deserialize_nullish. existing unit tests demonstrate
the equivalence. functions are private to the crate and safe to remove.

I added one assertion which demonstrates failing behavior for missing fields (which are *not*
covered by this deserializer). the behavior for that case is the same before and after
the change, it just wasn't tested.

also updated field documents and the helper function to explain the semantics.
Copy link
Collaborator

@jlizen jlizen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look great, thanks for this @jct-tympanon !

Can we have at least a couple fixtures capturing the migrated nullish handling though? (IE, missing the values). The existing fixtures already have contents.

@jct-tympanon
Copy link
Contributor Author

jct-tympanon commented Mar 19, 2026

Can we have at least a couple fixtures capturing the migrated nullish handling though? (IE, missing the values). The existing fixtures already have contents.

sure will do. i take it "fixtures" here means the sample documents like: https://github.com/aws/aws-lambda-rust-runtime/blob/main/lambda-events/src/fixtures/example-cognito-event-userpools-pretokengen-v2.json , plus test cases which read them.

@jlizen
Copy link
Collaborator

jlizen commented Mar 19, 2026

Yep, exactly! Much appreciated.

Following CR feedback on aws#1130 .

The selected cases cover booleans, dynamodb items, maps, and the GroupConfiguration data structure, so we have at least one instance of each nullish use case.

I added a utility function for basic serde verification. I retrofitted it to existing tests for the data structures that got new cases, just so the code is consistent for them. There are a very large number of other similar cases that I left alone to keep the review reasonable.
Copy link
Collaborator

@jlizen jlizen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks for handling all those other cases!

I'll start the release process today or tomorrow.

@jlizen jlizen merged commit bafe106 into aws:main Mar 19, 2026
12 checks passed
@darklight3it darklight3it mentioned this pull request Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CognitoEventUserPoolsPreTokenGenV2 deserialization error when groupConfiguration is null

2 participants